package com.woniu.user.service.impl;

import com.woniu.user.entity.UserInfo;
import com.woniu.user.entity.UserRealAuthentication;
import com.woniu.user.mapper.UserRealAuthenticationMapper;
import com.woniu.user.service.IUserInfoService;
import com.woniu.user.service.IUserRealAuthenticationService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 贾玉亮
 * @since 2023-01-02
 */
@Service
public class UserRealAuthenticationServiceImpl extends ServiceImpl<UserRealAuthenticationMapper, UserRealAuthentication> implements IUserRealAuthenticationService {
    @Resource
    IUserInfoService userInfoServiceImpl;
    @Resource
    UserRealAuthenticationMapper userRealAuthenticationMapper;

    @Override
    public int InferAuthentication(String mobile) {
        UserInfo userByMobile = userInfoServiceImpl.getUserByMobile(mobile);
        //实名认证状态
        String isAuthentication = userByMobile.getIsAuthentication();
        String auditStatus  = userRealAuthenticationMapper.InferAuthentication(userByMobile.getId());
        if (isAuthentication.equals("0") && auditStatus==null){
            //未审核 user 0 A 空
            return 0;
        }else if (isAuthentication.equals("0") && auditStatus.equals("2")){
            // 正在审核
            return 1;
        }else if (isAuthentication.equals("0") && auditStatus.equals("0")){
            // 审核未通过
            return 2;
        }
        // 审核通过
        return 3;
    }
}
